{extend name="$LAYOUT_WECHAT_BASE" /}
{block name="title"}确认订单 - {__block__}{/block}
{block name="css"}
<link rel="stylesheet"  href="__ROOT__/addons/groupon/view/wechat/index/css/settlement.css?v={$v}">
{/block}
{block name="header"}
    <header style="background:#ffffff;" class="ui-header ui-header-positive wst-header">
    	<a href="{:addon_url('groupon://goods/wxlists')}"><i class="ui-icon-return"></i></a><h1>确认订单</h1>
    </header>
{/block}
{block name="main"}
     {php}$shopFreight = 0;$shopIds = '';$freight = 0;{/php}
	 {php}
		if($carts['goodsType']==0 && !$carts['carts']['isFreeShipping']){
	        if(!empty($userAddress)){
	            $freight = WSTOrderFreight($carts['carts']['shopId'],$userAddress['areaId2'],$carts['carts']);
	            $shopFreight = $shopFreight + $freight;
	        }else{
	            $freight = 0;
	            $shopFreight = $shopFreight + $freight;
	        }
        }
     {/php}
     <section class="ui-container" style="border-bottom: 0.49rem solid transparent;">
       <input type="hidden" name="" value="{$carts['goodsType']}" id="goodsType" autocomplete="off">
       <input type="hidden" name="" value="{if isset($userAddress['addressId']) }{$userAddress['addressId']}{/if}" id="addressId" autocomplete="off">
	   <input type="hidden" name="" value="{if isset($userAddress['addressId']) }{$userAddress['areaId2']}{/if}" id="areaId" autocomplete="off">
       {if($carts['goodsType']==0)}
		<ul class="ui-list ui-list-text wst-se-address">
		    
		    {if empty($userAddress)}
			<li onclick="javascript:addAddress(1);" class="li-address">
				<div class="wst-flex-row wst-center" style="width:100%;">
					<i class="icon-add-address"></i><p class="infono">添加地址</p>
				</div>
			</li>
			{else}
			<li onclick="javascript:addAddress(1,{$userAddress['addressId']});" class="li-address">
				<div class="wst-flex-row wst-jsb wst-ac" style="width:100%;">
					<div class="wst-flex-column">
						<div class="wst-flex-row" style="align-items:baseline;"><i class="icon-address"></i><span class="infot">{$userAddress['userName']}</span><span class="infop">{$userAddress['userPhone']}</span></div>
						<div><span class="infob">{$userAddress['areaName']}{$userAddress['userAddress']}</span></div>
					</div>
					<i class="icon-right-arrow"></i>
				</div>
			</li>
		    {/if}
		    
		</ul>
		{/if}
		<div class="wst-se-sh">
			<p class="ui-nowrap-flex shopn wst-flex-row wst-ac" shopId="{$carts['carts']['shopId']}"><i></i>{$carts['carts']['shopName']}</p>
			<ul class="ui-row goods">
				<li class="ui-col ui-col-25">
					<div class="img">
						<a href="javascript:void(0);" onclick="javascript:goGoods({$carts['carts']['grouponId']});">
							<img src="__RESOURCE_PATH__/{:WSTConf('CONF.goodsLogo')}" data-echo="__RESOURCE_PATH__/{:WSTImg($carts['carts']['goods']['goodsImg'],3)}" title="{$carts['carts']['goods']['goodsName']|WSTStripTags}">
						</a>
					</div>
				</li>
				<li class="ui-col ui-col-75 wst-flex-column wst-jsb" style="height:0.9rem;">
					<ul class="ui-row info">
						<li class="ui-col ui-col-100">
							<div class="name"><p class="names">{$carts['carts']['goods']['goodsName']}</p>
								{if(!empty($carts['carts']['goods']['specNames']))}
								<p class="spec">
									{volist name="$carts['carts']['goods']['specNames']" id="sp"}
									{$sp['itemName']}
									{/volist}
								</p>
								{/if}</div>
						</li>
					</ul>
					<ul class="ui-row info">
						<li class="wst-flex-row wst-jsb wst-ac"><p class="price" >¥{$carts['carts']['goods']['shopPrice']}</p><p class="number">×{$carts['carts']['goods']['cartNum']}</p></li>
					</ul>
				</li>
			</ul>
			<div class="cost">
				<div class="wst-flex-row wst-jsb item"><span class="title">运费</span><span id="shopF">¥{php}echo sprintf("%.2f", $freight);{/php}</span></div>
				<div class="wst-flex-row wst-jsb item"><span class="title">店铺合计{if($carts['goodsType']==0)}(含运费){/if}</span><span id="shopC">¥{php}echo sprintf("%.2f",$freight+$carts['carts']['goodsMoney']);{/php}</span></div>
			</div>
			<div class="remarks wst-flex-row wst-jsb wst-ac">
				<span class="title">订单备注</span>
				<input id="remark_{$carts['carts']['shopId']}" maxLength='100' autocomplete="off" placeholder="填写订单备注" />
			</div>
		</div>
		<ul class="ui-list ui-list-text ui-list-active wst-se-mode" style="margin-bottom:0.1rem;">
			<li class="mode" onclick="javascript:dataShow('payments');">
				<h4 class="ui-nowrap">支付方式</h4>
				<div class="wst-flex-row wst-jfe wst-ac mode-content">
					<div class="ui-txt-info" id="paymentst">{if !empty($payments['1'])}{$payments['1']['0']['payName']}{else}{$payments['0']['0']['payName']}{/if}</div>
					<i class="icon-right-arrow"></i>
				</div>
			</li>
			{if($carts['goodsType']==0)}
			<li class="mode" onclick="javascript:dataShow('gives');">
				<h4 class="ui-nowrap">配送方式</h4>
				<div class="wst-flex-row wst-jfe wst-ac mode-content">
					<div class="ui-txt-info" id="givest">快递运输</div>
					<i class="icon-right-arrow"></i>
				</div>
			</li>
			{/if}
			{if($carts['carts']['isInvoice']==1)}
			<li onclick="javascript:getInvoiceList();">
				<h4 class="ui-nowrap">发票信息</h4>
				<div class="wst-flex-row wst-jfe wst-ac mode-content">
					<div class="ui-txt-info" id="invoicest">不开发票</div>
					<i class="icon-right-arrow"></i>
				</div>
			</li>
			{/if}
			{if(WSTConf('CONF.isOpenScorePay')==1)}
			<li onclick="javascript:dataShow('score');">
				<h4 class="ui-nowrap">积分支付</h4>
				<div class="wst-flex-row wst-jfe wst-ac mode-content">
					<div class="ui-txt-info" id="scoret">否</div>
					<i class="icon-right-arrow"></i>
				</div>
			</li>
			{/if}
		</ul>
     </section>
{/block}
{block name="footer"}
		{/* 大加载 */}
		<div class="ui-loading-block" id="Loadl">
		    <div class="ui-loading-cnt">
		        <i class="ui-loading-bright"></i>
		        <p id="j-Loadl">正在加载中...</p>
		    </div>
		</div>
		<footer class="ui-footer wst-footer-btns" style="height:0.49rem;" id="footer">
			<div class="wst-flex-row wst-jsb">
				<div class="wst-se-total wst-flex-column wst-jc wst-se-summary"><span class="title">应付总金额(含运费)：</span><span id="totalMoney">
					¥{if empty($userAddress)}
					 {php}echo sprintf("%.2f", $carts["goodsTotalMoney"]);{/php}
					 {else}
					 {php}echo sprintf("%.2f", $carts["goodsTotalMoney"]+$shopFreight);{/php}
					 {/if}</span></div>
				<div class="wst-se-confirm"><button class="button" onclick="javascript:submitOrder();">确定</button></div>
			</div>
		</footer>
{/block}
{block name="include"}
{/* 遮盖层  */}
<div class="wst-cover" id="cover"></div>
{/* 支付方式 */}
<input type="hidden" name="" value="{if !empty($payments['1'])}1{else}0{/if}" id="paymentsh" autocomplete="off">
<input type="hidden" name="" value="{if !empty($payments['1'])}{$payments['1']['0']['payCode']}{else}{$payments['0']['0']['payCode']}{/if}" id="paymentsw" autocomplete="off">
<div class="wst-fr-box frame" id="payments">
	<div class="title"><span>支付方式</span><div class="wst-clear"></div></div>
	<div class="content" id="content">
		{if !empty($payments)}
		{php}$paymentkey = 0;{/php}
		{volist name='$payments' id='paymentvo'}
		{volist name='$paymentvo' id='paymentitem'}
		<div class="fr-list wst-flex-row wst-jsb wst-ac" onclick="javascript:onSwitch(this);" >
			<div class="wst-list-infose1 wst-flex-row wst-ac"><i class="{$paymentitem['payCode']}"></i><span>{$paymentitem['payName']}</span></div>
			<i class="ui-icon-push payments_{$paymentitem['payCode']} ui-icon-checked-s" payCode="{$paymentitem['payCode']}" mode="{$paymentitem['isOnline']}" word="{$paymentitem['payName']}"></i>
		</div>
		{php}$paymentkey++;{/php}
		{/volist}
		{/volist}
		{/if}
	</div>
	<div class="bottom-two-btn-box wst-flex-row wst-center">
		<button type="button" class="button wst-dialog-b1" onclick="javascript:dataHide('payments');">取消</button>
		<button type="button" class="button wst-dialog-b2" onclick="javascript:inDetermine('payments');">确定</button>
	</div>
</div>
{/* 配送方式 */}
<input type="hidden" name="" value="0" id="givesh" autocomplete="off">
<div class="wst-fr-box frame" id="gives">
	<div class="title"><span>配送方式</span><div class="wst-clear"></div></div>
	<div class="content" id="content">
		<div class="fr-list wst-flex-row wst-jsb wst-ac" onclick="javascript:onSwitch(this);">
			<div class="wst-list-infose1 wst-flex-row wst-ac"><span>快递运输</span></div>
			<i class="ui-icon-push gives0 ui-icon-checked-s wst-active" mode="0" word="快递运输"></i>
		</div>
		<div class="fr-list wst-flex-row wst-jsb wst-ac" onclick="javascript:onSwitch(this);">
			<div class="wst-list-infose1 wst-flex-row wst-ac"><span>自提</span></div>
			<i class="ui-icon-push gives1 ui-icon-unchecked-s" mode="1" word="自提"></i>
		</div>
	</div>
	<div class="bottom-two-btn-box wst-flex-row wst-center">
		<button type="button" class="button wst-dialog-b1" onclick="javascript:dataHide('gives');">取消</button>
		<button type="button" class="button wst-dialog-b2" onclick="javascript:inDetermine('gives');">确定</button>
	</div>
</div>
{/* 用户发票列表  */}
<script type="text/html" id="invoiceBox">
	{{# for(var i = 0; i < d.length; i++){ }}
	<li class="{{ d[i].invoiceType==0?'j-normal':'j-special'  }}"
		invType="{{d[i].invoiceType}}"
		invId="{{d[i].id}}"
		invCode="{{d[i].invoiceCode}}">{{d[i].invoiceHead}}</li>
	{{# } }}
</script>

{/* 发票信息层  */}
<div class="wst-fr-box" id="frame" >
	<div class="title" id="boxTitle"><span>发票信息</span><div class="wst-clear"></div></div>
	<div class="content" id="invoice_content" style="height:4.32rem;">
		<div class="inv_item">
			<div class="inv_tit">发票类型</div>
			<div class="ui-list inv_ul wst-flex-row" id="j-normal-btn" onclick="javascript:invTypeSwitch(this,0);">
				<i class="ui-icon-push invoices0 ui-icon-checked-s wst-active inv_chk" mode="0" word="普通发票"></i>
				<div class="pdtb10"><span>普通发票</span></div>
			</div>
			<div class="ui-list inv_ul wst-flex-row" id="j-special-btn" onclick="javascript:invTypeSwitch(this,1);">
				<i class="ui-icon-push invoices1 ui-icon-unchecked-s inv_chk" mode="1" word="专用发票"></i>
				<div class="pdtb10"><span>专用发票</span></div>
			</div>
			<div class="wst-clear"></div>
		</div>
		<div class="inv_item" id="j-special-box">
			<div class="special_inv_hidebox" style="display: block">
				<div class="inv_head_inputbox">
					<input class="inv_head_input" readonly type="text" id="special_invoice_head" placeholder="请选择发票" />
					<div id="special_inv_headlist">
						<ul class="inv_list_item">
						</ul>
					</div>
				</div>
			</div>
		</div>
		<input type="hidden" id="invoiceId" value="0" />
		<input type="hidden" id="invoiceType" value="0" class='j-ipt' />
		<div class="inv_item" id='j-normal-box'>
			<div class="inv_tit">发票抬头</div>
			<div class="ui-list inv_ul wst-flex-row" onclick="javascript:invOnSwitch(this,0);">
				<i class="ui-icon-push invoices0 ui-icon-checked-s wst-active inv_chk" mode="0" word="个人"></i>
				<div class="pdtb10"><span>个人</span></div>
			</div>
			<div class="ui-list inv_ul wst-flex-row" onclick="javascript:invOnSwitch(this,1);">
				<i class="ui-icon-push invoices1 ui-icon-unchecked-s inv_chk" mode="1" word="单位"></i>
				<div class="pdtb10"><span>单位</span></div>
			</div>
			<input type="hidden" id="invoice_obj" value="0" />
			<div class="wst-clear"></div>

			<div class="inv_hidebox">
				<div class="inv_head_inputbox">
					<input class="inv_head_input" type="text" id="invoice_head" placeholder="请填写单位名称" />
					<div id="inv_headlist">
						<ul class="inv_list_item">
						</ul>
					</div>
				</div>
				<div class="inv_code_inputbox">
					<input class="inv_code_input" type="text" id="invoice_code" placeholder="请填写纳税人识别码" />
				</div>
			</div>
		</div>
		<div class="inv_item">
			<input type="hidden" id="isInvoice" value="0" />
			<div class="inv_tit">发票内容</div>
			<div class="wst-flex-row">
				<div class="ui-list inv_ul none_float wst-flex-row" onclick="javascript:isInvoice(this,0);">
					<i class="ui-icon-push invoices0 ui-icon-checked-s wst-active inv_chk" mode="0" word="不开发票"></i>
					<div class="pdtb10"><span>不开发票</span></div>
				</div>
				<div class="ui-list inv_ul none_float wst-flex-row" onclick="javascript:isInvoice(this,1);">
					<i class="ui-icon-push invoices1 ui-icon-unchecked-s inv_chk" mode="1" word="明细"></i>
					<div class="pdtb10"><span>明细</span></div>
				</div>
			</div>
			<div class="wst-clear"></div>
		</div>

		<ul class="inv_tip">
			<li>发票金额不包含优惠券和积分支付部分</li>
			<li>第三方卖家销售的商品发票由商家开具、寄出、发票内容由商家决定</li>
		</ul>
	</div>
	<div class="bottom-two-btn-box wst-flex-row wst-center">
		<button type="button" class="button wst-dialog-b1" onclick="javascript:invoiceHide();">取消</button>
		<button type="button" class="button wst-dialog-b2" onclick="javascript:saveInvoice();">确定</button>
	</div>
</div>

{/* 积分支付 */}
<input type="hidden" name="" value="0" id="scoreh" autocomplete="off">
<div class="wst-fr-box frame" id="score">
	<div class="title"><span>积分支付</span><div class="wst-clear"></div></div>
	<div class="content" id="content">
		<div class="fr-list wst-flex-row wst-jsb wst-ac" onclick="javascript:onSwitch(this);">
			<div class="wst-list-infose1 wst-flex-row wst-ac"><span>是</span></div>
			<i class="ui-icon-push score1 ui-icon-checked-s wst-active" mode="1" word="是"></i>
		</div>
		<div class="fr-list wst-flex-row wst-jsb wst-ac" onclick="javascript:onSwitch(this);">
			<div class="wst-list-infose1 wst-flex-row wst-ac"><span>否</span></div>
			<i class="ui-icon-push score0 ui-icon-unchecked-s" mode="0" word="否"></i>
		</div>
		<div class="wst-fr-score">（可用<span id="userOrderScore">{$userOrderScore}</span>个积分，可抵<span>¥<span id="userOrderMoney">{$userOrderMoney}</span></span>）</div>
	</div>
	<div class="bottom-two-btn-box wst-flex-row wst-center">
		<button type="button" class="button wst-dialog-b1" onclick="javascript:dataHide('score');">取消</button>
		<button type="button" class="button wst-dialog-b2" onclick="javascript:inDetermine('score');">确定</button>
	</div>
</div>
{/block}
{block name="js"}
<script type='text/javascript' src='__WECHAT__/js/jquery.min.js'></script>
<script type='text/javascript' src='__ROOT__/addons/groupon/view/wechat/index/js/settlement.js?v={$v}'></script>
{/block}